import { BasicColumn } from '@/components/Table';
import { FormSchema } from '@/components/Form';
import { DictEnum } from '@/enums/dictEnum';
import { getDictOptions } from '@/utils/dict';
import { renderDict } from '@/views/system/config/config.data';
import { shopInfoList } from '@/api/shop/manage/index';

export const formSchems: FormSchema[] = [
  {
    label: '店铺ID',
    field: 'shopId',
    component: 'Input',
  },
  {
    label: '店铺名称',
    field: 'shopId',
    component: 'ApiSelect',
    componentProps: {
      api: shopInfoList,
      showSearch: true,
      optionFilterProp: 'label',
      labelField: 'shopName',
      valueField: 'shopId',
    },
  },
  {
    label: '手环编码',
    field: 'braceletCode',
    component: 'Input',
  },
  {
    label: '手环状态',
    field: 'status',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DictEnum.BRACELET_STATUS_TYPE),
    },
  },
];

export const columns: BasicColumn[] = [
  {
    title: '店铺名称',
    dataIndex: 'shopName',
  },
  {
    title: '手环编码',
    dataIndex: 'braceletCode',
  },
  {
    title: '手环状态',
    dataIndex: 'status',
    customRender: ({ value }) => renderDict(value, DictEnum.SYS_SHOP_STATUS),
  },
  {
    title: '创建人',
    dataIndex: 'createBy',
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
  },
  {
    title: '更新人',
    dataIndex: 'updateBy',
  },
];

export const modalSchemas: FormSchema[] = [
  {
    label: '生成手环数量 ',
    field: 'braceletNum',
    required: true,
    component: 'InputNumber',
  },
  {
    label: '店铺名称',
    field: 'shopId',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: shopInfoList,
      showSearch: true,
      optionFilterProp: 'label',
      labelField: 'shopName',
      valueField: 'shopId',
    },
  },
];
